/**************************************************************************
*   Copyright (C) 2009 Chernov Dmitry                                     *
*   diman4ik.chernov@gmail.com                                            *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
*   This program is distributed in the hope that it will be useful,       *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
*   GNU General Public License for more details.                          *
*                                                                         *
*   You should have received a copy of the GNU General Public License     *
*   along with this program; if not, write to the                         *
*   Free Software Foundation, Inc.,                                       *
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
***************************************************************************/

#include "korners_time_line.h"


KornersTimeLine::KornersTimeLine()
{
    m_tml.setCurveShape( QTimeLine::LinearCurve );
    m_tml.setDirection( QTimeLine::Forward );

    connect( &m_tml, SIGNAL( frameChanged(int) ), SLOT( gotNewFrame(int) ) );
    connect( &m_tml, SIGNAL( finished() ), SLOT( tmlFinished() ) );

    m_running = false;
}

void KornersTimeLine::startFrames(int nFrames)
{
    m_tml.setCurrentTime(0);
    m_tml.setDuration( nFrames*500 );
    m_tml.setFrameRange( 0, nFrames );

    m_running = true;
    m_tml.start();
}

void KornersTimeLine::gotNewFrame(int nFrame)
{
    emit newFrame( nFrame );
}

void KornersTimeLine::tmlFinished()
{
    m_running = false;
    emit( finished() );
}

bool KornersTimeLine::running()
{
    return m_running;
}
